package cn.zhj.springboot.service.impl;

import cn.zhj.springboot.domain.Transferrecord;
import cn.zhj.springboot.mapper.TransferrecordMapper;
import cn.zhj.springboot.service.TransferrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransferrecordServiceImpl implements TransferrecordService {
    @Autowired
    private TransferrecordMapper transferrecordMapper;
    @Override
    public List<Transferrecord> getTransferrecordByUserId(Long userId) {
        return transferrecordMapper.getTransferrecordByUserId(userId);
    }

    @Override
    public void addTransferrecord(Long payerId, Long payeeId, Double money) {
        Transferrecord transferrecord = new Transferrecord();
        transferrecord.setPayerId(payerId);
        transferrecord.setPayeeId(payeeId);
        transferrecord.setAmount(money);
        transferrecord.setTransferTime(new java.util.Date());
        transferrecordMapper.addTransferrecord(transferrecord);
    }
}
